<template>
  <div class="container">
    <IForm :formFrame="frame" labelWidth="200px" class="form-container" :formData.sync="form"></IForm>
    <div slot="action">
      <!-- <a-button class="btn" @click="cancel">取消</a-button> -->
      <a-button class="btn" type="primary" @click="submit">保存</a-button>
    </div>
    <!-- <AttrEditor :form.sync="form">
			<div slot="action">
				<a-button class="btn" @click="cancel">取消</a-button>
				<a-button class="btn" type="primary" @click="submit">提交</a-button>
			</div>
		</AttrEditor> -->

  </div>
</template>

<script>
  // import AttrEditor from "./components/AttrEditor"
  import IForm from "@/components/IForm"

  const resourceType = 'fudai_robot'

  export default {
    components: {
      IForm
      // AttrEditor
    },
    data() {
      return {
        uuid: '',
        form: {
          banner: []
        },
        categoryList: []
      }
    },
    computed: {
      categoryOptions() {
        return this.categoryList.map(item => {
          return {
            title: item.title,
            value: item.id
          }
        })
      },
      frame() {
        return [
          {
            type: 'blank',
            tips: '每天23点时生成次日任务,这里只是方便生成的,不影响原先的机器人逻辑和设置.',
          },
          {
            title: '总机器人开关',
            key: 'is_all_enabled',
            type: 'boolean',
            placeholder: '',
            // span: 12,
            tips: '关闭后后全平台机器人抽赏,转售回收将暂停',
            newline: true,
            required: true,
          },
          {
            title: '福袋机器人开关',
            key: 'is_enabled',
            type: 'boolean',
            placeholder: '',
            // span: 12,
            tips: '关闭后下方设置到点将不会生成,对已生成的无效',
            newline: true,
            required: true,
          },
          {
            title: '连抽类型',
            key: 'level',
            type: 'radio',
            default: 10,
            required: true,
            span: 24,
            options: [{
                title: '1发',
                value: 1
              },
              {
                title: '3发',
                value: 3
              },
              {
                title: '10发',
                value: 10
              },
              {
                title: '随机',
                value: 0
              }
            ],
            tips: ''
          },
          {
            title: '最小抽奖次数',
            key: 'min_log_num',
            type: 'number',
            newline: true,
            required: true,
            default: 20,
          },
          {
            title: '最大抽奖次数',
            key: 'max_log_num',
            type: 'number',
            newline: true,
            required: true,
            default: 60,
          },
          {
            title: '最小人数',
            key: 'min_all_num',
            type: 'number',
            newline: true,
            default: 30,
          },
          {
            title: '最大人数',
            key: 'max_all_num',
            type: 'number',
            newline: true,
            default: 50,
          },
          {
            title: '最小任务间隔',
            key: 'min_interval',
            type: 'number',
            required: true,
            suffix: '秒,每个用户多任务时',
            default: 3,
            newline: true,
          },
          {
            title: '最大任务间隔',
            key: 'max_interval',
            type: 'number',
            required: true,
            suffix: '秒,每个用户多任务时',
            default: 60,
            newline: true,
          },
          {
            title: '最小用户间隔',
            key: 'min_user',
            type: 'number',
            suffix: '秒,多用户时使用',
            newline: true,
            default: 120,
          },
          {
            title: '最大用户间隔',
            key: 'max_user',
            type: 'number',
            suffix: '秒,多用户时使用',
            newline: true,
            default: 3600,
          },
          {
            title: '随机去其他池子概率',
            key: 'qt_gl',
            type: 'number',
            suffix: '%',
            newline: true,
            default: 20,
          },
          {
            title: '去了之后回来概率',
            key: 'hl_gl',
            type: 'number',
            suffix: '%',
            tips: '回来后根据上面(随机去其他池子概率)再去其他池子',
            newline: true,
            default: 30,
          },
          {
            title: '福袋列表',
            key: 'list',
            type: 'activity_list_input',
            activity_type: 'fudai',
            span: 24,
            placeholder: '请输入',
            newline: true
          },
        ]
      }
    },
    created() {
      this.$http.get(`/setting/sys/${resourceType}`).then(res => {
        this.form = res.data.setting || {}
        // this.form.return_type = this.form.return_type || 'money'
      })
    },
    mounted() {},
    watch: {},
    methods: {
      cancel() {
        this.$router.back(-1)
      },
      submit() {
        this.$http.post(`/setting/sys/${resourceType}`, {
          setting: this.form
        }).then(res => {
          this.$message.success('保存成功')
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .form-container {
    padding-bottom: 120px;
  }

  .container {
    .btn {
      margin-right: 30px;
    }
  }
</style>
